//
//  FYHIndexViewController.m
//  FollowYourHeart
//
//  Created by lanou3g on 16/3/11.
//  Copyright © 2016年 李晨玲. All rights reserved.
//

#import "FYHIndexViewController.h"
#import <Masonry.h>
#import "FYHTypeClass.h"


@interface FYHIndexViewController ()
{
    UIButton *button11;
    UIButton *button12;
    UIButton *button13;
    UIButton *button14;
    UIButton *_selectBtn;
    
}
@end

@implementation FYHIndexViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setViews];/** 页面布局*/
    self.view.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"zhijiage.jpg"]];
    
 
//    UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
//    UIVisualEffectView *view = [[UIVisualEffectView alloc]initWithEffect:beffect];
//    view.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight + 64);
//    view.userInteractionEnabled = YES;
    
    
    
}



- (void)setViews{
    
    /** 横线*/
    UIView *viewHengxian = [[UIView alloc] init];
    viewHengxian.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:viewHengxian];
    [viewHengxian mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view).with.offset(100);
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(ScreenW);
        
    }];
    
    UILabel *labletitleC =[[UILabel alloc] init];
    labletitleC.text = @"芝加哥";
    labletitleC.textColor = [UIColor whiteColor];
    [self.view addSubview:labletitleC];
    UILabel *labletitleE =[[UILabel alloc] init];
    labletitleE.text = @"Chicago";
    labletitleE.textColor = [UIColor whiteColor];
    labletitleC.font =[UIFont systemFontOfSize:25];
    [self.view addSubview:labletitleE];
    
    [labletitleC mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.height.equalTo(@50);
        make.top.equalTo(@200);
        
    }];
    [labletitleE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.height.equalTo(@20);
        make.top.equalTo(labletitleC).with.offset(50);
        
    }];
    button11 = [[UIButton alloc] init];
    button12 = [[UIButton alloc] init];
    button13 = [[UIButton alloc] init];
    button14 = [[UIButton alloc] init];
    
    button11.tag = 101;
    button12.tag = 102;
    button13.tag = 103;
    button14.tag = 104;
   
    button11.backgroundColor = [UIColor redColor];
    button12.backgroundColor = [UIColor grayColor];
    button13.backgroundColor = [UIColor greenColor];
    button14.backgroundColor = [UIColor cyanColor];
   
    [self.view addSubview:button11];
    [self.view addSubview:button12];
    [self.view addSubview:button13];
    [self.view addSubview:button14];
   
    [self setButtonImage:@"iconfont-jingdian.png" button:button11];
    [self setButtonImage:@"iconfont-canting.png" button:button12];
    [self setButtonImage:@"iconfont-jiudian.png" button:button13];
    [self setButtonImage:@"iconfont-gouwu.png" button:button14];
    
    UILabel *lable11 = [[UILabel alloc] init];
    UILabel *lable12 = [[UILabel alloc] init];
    UILabel *lable13 = [[UILabel alloc] init];
    UILabel *lable14 = [[UILabel alloc] init];

    [self.view addSubview:lable11];
    [self.view addSubview:lable12];
    [self.view addSubview:lable13];
    [self.view addSubview:lable14];
   
    lable11.text = @"景点";
    lable12.text = @"餐厅";
    lable13.text = @"酒店";
    lable14.text = @"购物";
  
    lable11.textColor = [UIColor whiteColor];
    lable12.textColor = [UIColor whiteColor];
    lable13.textColor = [UIColor whiteColor];
    lable14.textColor = [UIColor whiteColor];
   
    lable11.textAlignment = NSTextAlignmentCenter;
    lable12.textAlignment = NSTextAlignmentCenter;
    lable13.textAlignment = NSTextAlignmentCenter;
    lable14.textAlignment = NSTextAlignmentCenter;
   
    CGFloat padding1 = (ScreenW-50*4)/5;//间距
    [button11 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(50, 50));
        make.top.equalTo(self.view.mas_bottom).with.offset(-150);
        make.left.equalTo(self.view).with.offset(padding1);
        
    }];
    [button12 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(button11);
        make.centerY.equalTo(button11);
        make.left.equalTo(button11.mas_right).with.offset(padding1);
        
    }];
    [button13 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(button11);
        make.centerY.equalTo(button11);
        make.left.equalTo(button12.mas_right).with.offset(padding1);
    }];
    [button14 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(button11);
        make.centerY.equalTo(button11);
        make.left.equalTo(button13.mas_right).with.offset(padding1);
    }];
   
    
    [lable11 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(50, 20));
        make.centerX.equalTo(button11);
        make.top.equalTo(button11.mas_bottom).with.offset(10);
    }];
    [lable12 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(lable11);
        make.centerX.equalTo(button12);
        make.centerY.equalTo(lable11);
    }];
    [lable13 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(lable11);
        make.centerY.equalTo(lable11);
        make.centerX.equalTo(button13);
    }];
    [lable14 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(lable11);
        make.centerX.equalTo(button14);
        make.top.equalTo(button14.mas_bottom).with.offset(10);
        
    }];
  
    [button11 addTarget:self action:@selector(selectbutton:) forControlEvents:(UIControlEventTouchDown)];
    [button12 addTarget:self action:@selector(selectbutton:) forControlEvents:(UIControlEventTouchDown)];
    [button13 addTarget:self action:@selector(selectbutton:) forControlEvents:(UIControlEventTouchDown)];
    [button14 addTarget:self action:@selector(selectbutton:) forControlEvents:(UIControlEventTouchDown)];
    
    
    
}

- (void)setButtonImage:(NSString *)str button:(UIButton *)button{
    [button setImage:[UIImage imageNamed:str] forState:(UIControlStateNormal)];
    button.layer.masksToBounds = YES;
    button.layer.borderWidth = 0.1;
    button.layer.cornerRadius = 25;
    
    
}
- (void)selectbutton:(UIButton *)sender{
    if (sender == button11) {
        sender.tag = button11.tag; //创建个属性,传值
    }
    if (sender == button12) {
         sender.tag = button12.tag; //创建个属性,传值
    }
    if (sender == button13) {
         sender.tag = button13.tag; //创建个属性,传值
    }
    if (sender == button14) {
         sender.tag = button14.tag; //创建个属性,传值
    }
    
    FYHTypeClass *typeVC =[[FYHTypeClass alloc] init];
    typeVC.btnTarge = sender.tag;
    [self presentViewController:typeVC animated:YES completion:nil];
    
}


    


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
